<template>
    <div class="balance_detail">
        <van-nav-bar title="余额明细" left-arrow fixed @click-left="onClickLeft" />
        <div class="balance_detail_top">
            <div>1000.00</div>
            <div>未结算余额</div>
        </div>
        <div class="balance_detail_content">
            <div class="balance_detail_content_day" @click="dayShow = true">{{ days }}<van-icon name="arrow-down"
                    style="color: #999;" /></div>
            <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                <div class="balance_list" v-for="(item, index) in 3" :key="index">
                    <div class="balance_list_left">
                        <div>用户线上商城购买</div>
                        <div>2023-10-20 10:20:00</div>
                    </div>
                    <div class="balance_list_right">+100.00</div>
                </div>
            </van-list>
        </div>

        <van-popup v-model="dayShow" position="bottom" :style="{ height: '40%' }">
            <van-datetime-picker :value="new Date(currentDate)" type="date" title="选择年月日" :min-date="minDate"
                :max-date="maxDate" @confirm="onConfirmDay" @cancel="onCancelDay" />
        </van-popup>
    </div>
</template>
<script>
import { parseTime } from '@/tool/methods'
export default {
    name: 'balance',
    data() {
        return {
            days: "本月",
            dayShow: false,
            minDate: new Date(1930, 0, 1),
            maxDate: new Date(2999, 10, 1),
            currentDate: new Date(),
            loading: false,
            finished: false,
            notifyList: []
        }
    },
    created() {

    },
    methods: {
        onClickLeft() {
            this.$router.back()
        },
        onConfirmDay(val) {
            this.currentDate = parseTime(val, '{y}-{m}-{d}')
            this.days = this.currentDate
            // this.year = this.currentDate.split('-')[0]
            // this.month = this.currentDate.split('-')[1]
            // this.day = this.currentDate.split('-')[2]
            this.dayShow = false
            // this.page = 1
            // this.fansList = []
            // this.onLoad()
        },
        onCancelDay() {
            this.dayShow = false
            // this.days = null
            this.days = '本月'
            // this.selectedItems[2]=false
            // this.year = ''
            // this.month = ''
            // this.day = ''
            // this.page = 1
            // this.fansList = []
            // this.onLoad()
        },
        onLoad() {

        }
    }
}
</script>
<style lang="scss" scoped>
.balance_detail {
    padding-top: 46px;
    background-color: #F2F4F5;
    height: calc(100vh - 46px);

    ::v-deep .van-hairline--bottom::after {
        border: none;
    }

    ::v-deep .van-icon {
        color: #fff;
    }

    ::v-deep .van-nav-bar__title {
        color: #fff;
    }

    ::v-deep .van-nav-bar__arrow {
        font-size: 20px;
    }

    ::v-deep .van-nav-bar__text {
        color: #fff;
    }

    ::v-deep .van-nav-bar {
        background: transparent;
        position: fixed; // 改为固定定位
        top: 0; // 添加这行
        left: 0; // 添加这行
        right: 0; // 添加这行
        z-index: 1000; // 添加这行，确保它在其他元素之上

        // position: fixed;
        &.scrolled {
            background-color: #ffffff; // 或者你想要的任何颜色

            .van-nav-bar__title,
            .van-icon,
            .van-nav-bar__text {
                color: #333; // 滚动后变为黑色
            }
        }
    }

    .balance_detail_top {
        width: 100%;
        height: 4.72rem;
        background: url('../../../images/mine/img_beij4.png') no-repeat center;
        position: relative;
        /* 相对定位 */
        top: -46px;
        /* 根据你的 NavBar 高度调整，Vant UI 默认 NavBar 高度为 46px */
        width: 100%;
        background-size: cover;
        color: #fff;
        text-align: center;
        padding-top: 1.5rem;
        box-sizing: border-box;

        div:nth-child(1) {
            font-family: PingFangSC, PingFang SC;
            font-weight: 500;
            font-size: .6rem;
            color: #FFFFFF;
            line-height: .84rem;
            // text-align: right;
            font-style: normal
        }

        div:nth-child(2) {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: .32rem;
            color: #FFFFFF;
            line-height: .44rem;
            // text-align: right;
            font-style: normal;
            margin-top: .12rem;
        }
    }

    .balance_detail_content {
        width: 95%;
        height: calc(100vh - 4rem);
        margin: 0 auto;
        border-radius: .2rem;
        // border-top-right-radius: .2rem;
        background: #fff;
        padding-top: .4rem;
        box-sizing: border-box;
        margin-top: -1.9rem;
        position: relative;
        z-index: 1;
        padding: .2rem;
        box-sizing: border-box;

        .balance_detail_content_day {
            min-width: 1.2rem;
            max-width: 2rem;
            border-radius: .36rem;
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: .24rem;
            color: #666666;
            padding: .08rem 0;
            box-sizing: border-box;
            text-align: center;
            font-style: normal;
            border: 1px solid #8A8A8A;

            ::v-deep .van-icon {
                color: #666;
            }
        }

        .balance_list {
            margin-top: .2rem;
            padding-bottom: .2rem;
            border-bottom: 1px solid #E5E5E5;
            display: flex;
            justify-content: space-between;

            .balance_list_left {
                font-family: PingFangSC, PingFang SC;
                font-weight: 400;
                font-size: .28rem;
                color: #333333;
                line-height: .4rem;
                // text-align: left;
                font-style: normal;

                div:last-child {
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 400;
                    font-size: .24rem;
                    color: #999999;
                    line-height: .34rem;
                    // text-align: left;
                    font-style: normal;
                    margin-top: .12rem;

                }
            }

            .balance_list_right {
                font-family: PingFangSC, PingFang SC;
                font-weight: 500;
                font-size: .32rem;
                color: #55A624;
                line-height: .44rem;
                // text-align: center;
                font-style: normal;
            }
        }

    }
}
</style>